package com.training.java.core.homework02;

public class LaptopArrayDemo02 {

	public static void main(String[] args) {
		LaptopLocations location;

		// Creating an empty array of 3 elements that will hold addresses of Laptop objects.
		Laptop[] laptops = new Laptop[3];

		// Instantiating actual Laptop objects and initializing the array in a loop.
		for(int i=0; i < laptops.length; i++) {
			if(i == 0) {
				location = LaptopLocations.HOME;
			} else if(i == 1) {
				location = LaptopLocations.WORK;
			} else {
				location = LaptopLocations.STARBUCKS;
			}

			laptops[i] = new Laptop(location);
		}
		
		// Reading array in traditional for loop and starting & stopping each one.
		System.out.println("");
		System.out.println("Reading and starting/stopping in traditional for loop");
		System.out.println("-----------------------------------------------------");
		for (int i = 0; i < laptops.length; i++) {
			laptops[i].start();
			laptops[i].stop();
		}
		
		// Reading array in enhanced for each loop and starting & stopping each one.
		System.out.println("");
		System.out.println("Reading and starting/stopping in enhanced for loop");
		System.out.println("--------------------------------------------------");
		for (Laptop laptop : laptops) {
			laptop.start();
			laptop.stop();
		}
	}
}
